var webshot = require('webshot');
var express = require('express');
var app = express();

app.get('/genImage/:url', function (req, res) {
    console.log('目标地址：' + req.params.url)

    screenshot = '';
    var renderStream = webshot(req.params.url);

    renderStream.on('data', function (data) {
        screenshot += data.toString('binary');
    });

    renderStream.on('end', function () {
        res.set('Content-Type', 'image/png');
        res.end(screenshot, 'binary');
    });
})

var server = app.listen(9053, function () {
    console.log('服务运行在http://0.0.0.0:9053/genImage/urlEncode地址')
})
